<template>
	<div class="qBody">
		<div class="banner">
			<image src="https://www.baixuemianshi.com/zhuanti/images/banner_skcjwt.jpg" mode="widthFix"></image>
		</div>
		<u-sticky>
			<div class="searchBox">
				<u-search placeholder="请输入问题关键字" v-model="keyword"></u-search>
			</div>
		</u-sticky>
		<div class="container">
			<div class="qList">
				<div class="item" v-for="(item,index) in showList" :key="index" @click="getDetail(item)">
					<h3> {{ item.question }}</h3>
					<div class="answer">{{ item.answer }}</div>
				</div>
			</div>
		</div>
		
		<u-popup :show="detail" @close="detail = ''" mode="center" :closeable="true">
			<div class="popContent">
				<h3>{{ detail.question }}</h3>
				<div class="answer">{{ detail.answer }}</div>
			</div>
		</u-popup>
		<share></share>
		<div class="name">{{name}}</div>
	</div>
</template>

<script>
	import {
		mapActions
	} from 'vuex';
	const db = wx.cloud.database()
	import share from '../../common/share/index.vue';
	export default {
		data() {
			return {
				klcode:"",
				name: '',
				searchNum: 0,
				detail: "",
				qList: [],
				keyword: "",
			};
		},
		onShareAppMessage(options) {
			let shareObj = {
			    title: "考编常见问题",
			    path: '/pages/sk-tools/questions/index?name=' + this.name,
			    imageUrl: ''   
			};
			return shareObj
		},
		onShareTimeline(res) {
			let that = this;
			return {
				title: '考编常见问题',
				query: "name=" + that.name
			};
		},
		onLoad(options) {
			if (!options) {} else {
				this.name = options.name
			}
		},
		computed: {
			userphone() {
				return this.$store.getters.userphone ? this.$store.getters.userphone : '';
			},
			username() {
				return this.$store.getters.username ? this.$store.getters.username : '';
			},
			loginpage() {
				return this.$store.getters.loginpage ? this.$store.getters.loginpage : '';
			},
			showList(){
				// if(!this.keyword){
				// 	return this.qList
				// }
				let a = this.qList.filter(item => item.question.indexOf(this.keyword)  != -1)
				return a
			}
		},
		mounted() {
			
		},
		watch: {
			
		},
		created() {
			let that = this;
			that.getAllQus()
		},
		methods: {
			...mapActions(['LogSetSearchtimes','LogSetPhone','LogSetOpenid','LogSetName','LogSetPage','LogSetFavzw']),
			
			
			getAllQus() {
				let that = this
				
				uni.request({
					url: 'https://www.baixuemianshi.com/zhuanti/sk-tools/questions.js',
					method: 'get',
					dataType: 'text',
					data: {
						sstimes: new Date()
					},
					success: function(res) {
						var resjson = JSON.parse(res.data);
						that.qList = resjson
					}
				});
			},
			getDetail(item){
				this.detail = item
			}
			
		},
		components: {share}
	};
</script>

<style lang="scss">
	@import url(./index.css);
</style>
